<?php

class worker
{
	public function start()
	{	
		// 检查网站配置， 是否暂停服务
		$config = bone::get_config('system');
		if($config->offline)
		{
			exit($config->offline_message);
		}

		// 启动 session
		bone::get_session();

		// 调用自动运行文件
		$dir = dir(BONE_ROOT.DS.'autorun');
		while (($file = $dir->read()) !== false)
		{
			if($file!='.' && $file!='..' && !is_dir( BONE_ROOT.DS.'autorun'.DS.$file ))
				include( BONE_ROOT.DS.'autorun'.DS.$file );
		}
		$dir->close();
		
	}

	public function work()
	{
		$controller = request('controller', 'home');
		$task = request('task', 'home');
		$controller = bone::get_controller($controller);
		$controller->execute($task);
	}

	public function stop()
	{
		// 回收资源

	}
}
